package com.bilibili.domain;

/**
 * 统一返回类
 *
 * @param <T>
 */
public class Result<T> {

    private String code;
    private String msg;
    private T data;

    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(T data) {
        this.data = data;
        msg = "成功";
        code = "0";
    }

    public static Result<String> success() {
        return new Result<String>(null);
    }

    public static Result<String> success(String data) {
        return new Result<String>(data);
    }

    public static Result<String> fail() {
        return new Result<>("1", "失败");
    }

    public static Result<String> fail(String code, String msg) {
        return new Result<>(code, msg);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
